home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 21 code / Hierarchical Lists / Libs / CTwistDownListBox.h < prev   
Encoding:
Text File  |  1994-09-12  |  2.4 KB  |  86 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //    LHierarchicalListBox.h            ©1994 Jan Bruyndonckx All rights reserved.
  3. //    v1.0 18/6/94
  4. //
  5. //    A hierarchical listbox subclass.  The listbox contains only string data.
  6. // ===========================================================================
  7.  
  8. #pragma once
  9.  
  10. #include "CCustomListBox.h"
  11.  
  12. //----------------------------------------------------------------------------
  13.  
  14. typedef enum {
  15.     kHasSubList       = 0x01,            // item contains sub-items (eg. folder)
  16.     kIsOpened          = 0x02,            // the item is opened
  17.     kDrawFilled       = 0x04,            // draw the triangle filled
  18.     kDrawIntermediate = 0x08            // draw intermediate state
  19. } TwistFlags ;
  20.  
  21. #if defined(powerc)
  22.  #pragma options align=mac68k
  23. #endif
  24.  
  25. #define TWIST_DOWN_HEAD                                \
  26.     Byte    indent ;    /* indentation level    */    \
  27.     Byte    flags ;        /* display flags        */
  28.  
  29. typedef struct {
  30.     TWIST_DOWN_HEAD
  31. } TwistDownHeader ;
  32.  
  33. typedef struct {
  34.     TWIST_DOWN_HEAD    
  35.     Byte    data[2] ;    // variable length of data (default=P-String)
  36. } TwistDownRec, *TwistDownRecPtr ;
  37.  
  38. #if defined(powerc)
  39.  #pragma options align=reset
  40. #endif
  41.  
  42. #define TwistDownRecSize     (sizeof(TwistDownHeader))    // don't count the variable 'data' field
  43.  
  44. //----------------------------------------------------------------------------
  45.  
  46. class CTwistDownListBox : public CCustomListBox {
  47.  
  48.   public:
  49.       enum {
  50.           classID = 'hlst'
  51.       } ;
  52.         
  53.     static CTwistDownListBox*    CreateFromStream(LStream *inStream);
  54.  
  55.     CTwistDownListBox() ;
  56.     CTwistDownListBox(const SPaneInfo &inPaneInfo,
  57.                         Boolean inHasHorizScroll, Boolean inHasVertScroll,
  58.                         Boolean inHasGrow, Boolean inHasFocusBox,
  59.                         MessageT inDoubleClickMessage, Int16 inTextTraitsID,
  60.                         LCommander *inSuper);
  61.     CTwistDownListBox(LStream *inStream);
  62.  
  63.     virtual StringPtr    GetDescriptor(Str255 outDescriptor) const;
  64.     virtual void        SetDescriptor(ConstStr255Param inDescriptor);
  65.     
  66.   protected:
  67.       short    triangleWidth ;            // width of the triangle area
  68.       
  69.     virtual void    ClickSelf(const SMouseDownEvent &inMouseDown);
  70.     virtual void    DrawElementSelf (const Rect *lRect, 
  71.                                      const void *lElement,
  72.                                      const short lDataLen) ;
  73.     virtual void    DrawTwistedElement (const Rect *lRect,
  74.                                         const TwistDownRecPtr twistElement,
  75.                                         const short lDataLen) ;
  76.  
  77.     virtual void    CollapseElement (const Cell theCell) ;
  78.     virtual void    ExpandElement (const Cell theCell) ;
  79.  
  80.   private:
  81.       void            init (void) ;
  82.       
  83.       static    PolyHandle    sClosedPoly,
  84.                           sOpenedPoly,
  85.                           sIntermediatePoly ;
  86. } ;